/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.stuffrepos.bricknetcenter.http.util;

import java.net.MalformedURLException;
import java.net.URL;
import net.stuffrepos.bricknetcenter.http.HttpParser;
import net.stuffrepos.bricknetcenter.http.HttpRequest;
import net.stuffrepos.bricknetcenter.http.HttpResponse;

/**
 *
 * @author Eduardo H. Bogoni <eduardobogoni@gmail.com>
 */
public class LinkPage implements HttpRequest {

    private final URL referer;
    private final URL url;
    private final Class<? extends HttpParser> parserClass;
    private int priority;
    private final Method method = Method.Get;

    public LinkPage(HttpResponse response, String href, Class<? extends HttpParser> parserClass) throws MalformedURLException {
        this(response, href, parserClass, 0);
    }

    public LinkPage(HttpResponse response, String href, Class<? extends HttpParser> parserClass, int priority) throws MalformedURLException {
        this.referer = response.getUrl();
        this.url = new URL(response.getUrl(), href);
        this.parserClass = parserClass;
        this.priority = priority;
    }

    @Override
    public URL getUrl() {
        return url;
    }

    @Override
    public URL getReferer() {
        return referer;
    }

    @Override
    public Class<? extends HttpParser> getParserClass() {
        return parserClass;
    }

    @Override
    public Object[] getParserArguments() {
        return new Object[0];
    }

    @Override
    public int getPriority() {
        return priority;
    }

    @Override
    public PostParameter[] getPostParameters() {
        return new PostParameter[0];
    }

    @Override
    public Method getMethod() {
        return Method.Get;
    }
}
